<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <div th:replace="~{/home::css_js}"></div>

</head>

<script th:inline="javascript">
    var msg=[[${msg}]];
    if(msg!=null)
        alert(msg);
    msg=null;
</script>

<body>
<div id="wrapper">

    <div th:replace="~{/home::topbar}"></div>

    <div th:replace="~{/home::sidebar}"></div>

    <div class="main">
        <!-- MAIN CONTENT -->


        <div class="main-content">
            <div class="container-fluid">

                <div id="page-inner">
                    <div class="row">
                        <div class="col-md-12">
                            <!-- Advanced Tables -->
                            <div class="card">
                                <div class="card-action">
                                    系统管理员列表
                                </div>
                                <div class="card-content">
                                    <div class="table-responsive">                      <!--注意这个table标签的id=""-->
                                        <table class="table table-striped table-bordered table-hover"
                                               id="datatable">
                                            <thead>
                                            <tr>
                                                <th>管理员编号</th>
                                                <th>用户名</th>
                                                <th>密码</th>
                                                <th>角色</th>
                                                <th>账号状态</th>
                                                <th>姓名</th>
                                                <th>电话</th>
                                                <th>邮箱</th>
                                                <th>创建日期</th>
                                                <th>最后修改日期</th>
                                                <th>选项</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <tr class="odd gradeX" th:each="admin:${admin_s}">
                                                <td th:text="${admin.getAdmin_id()}"></td>
                                                <td th:text="${admin.getUsername()}"></td>
                                                <td th:text="${admin.getPassword()}"></td>
                                                <div th:switch="${admin.getRole()}">
                                                    <td th:case="0" th:text="超级管理员"></td>
                                                    <td th:case="1" th:text="系统管理员"></td>
                                                    <td th:case="*" th:text="/"></td>
                                                </div>
                                                <div th:switch="${admin.getState()}">
                                                    <td th:case="1" th:text="正常"></td>
                                                    <td th:case="0" th:text="冻结"></td>
                                                    <td th:case="*" th:text="未启用"></td>
                                                </div>
                                                <td th:text="${admin.getRealname()}"></td>
                                                <td th:text="${admin.getPhone()}"></td>
                                                <td th:text="${admin.getEmail()}"></td>
                                                <td th:text="${#dates.format(admin.getAdd_date(),'yyyy-MM-dd HH:mm:ss')}"></td>
                                                <td th:text="${#dates.format(admin.getUpdate_date(),'yyyy-MM-dd HH:mm:ss')}"></td>
                                                <td th:switch="${admin.getRole()}">
                                                    <div th:case="1">
                                                    <a class="btn btn-sm btn-primary" th:href="@{'/admin/modify_admin/'+${admin.getAdmin_id()}}">修改</a>
                                                    <a class="btn btn-sm btn-danger" th:href="@{'/admin/delete_admin/'+${admin.getAdmin_id()}}">删除</a>
                                                    </div>
                                                    <div th:case="2">
                                                        <a class="btn btn-sm btn-primary" th:href="@{'/admin/modify_admin/'+${admin.getAdmin_id()}}">修改</a>
                                                        <a class="btn btn-sm btn-danger" th:href="@{'/admin/delete_admin/'+${admin.getAdmin_id()}}">删除</a>
                                                    </div>
                                                </td>
                                            </tr>
                                            </tbody>
                                        </table>

                                    </div>
                                </div>
                            </div>
                        </div> <!--col 12 结束-->
                    </div> <!--row 结束-->
                </div><!--page inner结束-->
            </div><!-- container-fluid 结束-->
        </div><!-- main-content 结束-->
    </div><!--main结束-->
</div><!--wrapper结束-->


<script th:src="@{/js/jquery-1.10.2.js}"></script> <!--缺少这个，表格分页，查找失效-->
<!--<script th:src="@{/js/bootstrap.min.js}"></script>-->
<!--上面的js引用后，顶部头像dropdown失效-->
<script th:src="@{/js/jquery.dataTables.js}"></script>
<script th:src="@{/js/dataTables.bootstrap.js}"></script>
<link th:href="@{/css/dataTables.bootstrap.css}">
<script>
    $(document).ready(function () {
        $('#datatable').dataTable(
            {

            language: {
                "sProcessing": "处理中...",
                "sLengthMenu": "显示 _MENU_ 项结果",
                "sZeroRecords": "没有匹配结果",
                "sInfo": "显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项",
                "sInfoEmpty": "显示第 0 至 0 项结果，共 0 项",
                "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
                "sInfoPostFix": "",
                "sSearch": "搜索:",
                "sUrl": "",
                "sEmptyTable": "表中数据为空",
                "sLoadingRecords": "载入中...",
                "sInfoThousands": ",",
                "oPaginate": {
                    "sFirst": "首页",
                    "sPrevious": "上页",
                    "sNext": "下页",
                    "sLast": "末页"
                },
                "oAria": {
                    "sSortAscending": ": 以升序排列此列",
                    "sSortDescending": ": 以降序排列此列"
                }
            }
        }
        ); //dataTable()结束

    });
</script>

</body>
</html>